//minimum range query tree
//Max number of nodes in binary tree with N leafs is 2* 2^(log2(N)+1)
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>

#include <cmath>
#include <cstdio>
#include <cstdlib>

using namespace std;
#define Int int
#define SZ(X) (int)(X).size()
#define bip char ch;\
      ch = getchar() ;


struct NODE{
        Int _from;
        Int _to;
        Int _val;
        NODE(Int from_=0, Int to_=0, Int val_=0):
        _from(from_),_to(to_),_val(val_){}
};
vector< NODE > tree;
vector< Int  > vt;
Int N = 5 ; // leaf numbers

inline void buildTree(Int node, Int from , Int to){

        tree[ node ]._from = from;
        tree[ node ]._to   = to;
        if( from==to ){
                tree[ node ]._val = from;
                return ;
        }
        
        Int mid = (from+to)/2 ;
        
        Int lChild = (node*2)+1;
        Int rChild = (node*2)+2;
        buildTree( lChild , from , mid );
        buildTree( rChild , mid+1, to  );
        
        Int Lvalue = vt[ tree[ lChild ]._val ];
        Int Rvalue = vt[ tree[ rChild ]._val ];
        
        if(Lvalue < Rvalue){
                tree[ node ]._val = tree[ lChild ]._val;
        }
        else{
                tree[ node ]._val = tree[ rChild ]._val;
        }
return ;
}
inline void read(){
        vt.assign(6,0);
        vt[0]=1;
        vt[1]=5;
        vt[2]=4;
        vt[3]=3;
        vt[4]=7;
        vt[5]=20;
return ;
}
inline int queryTree(Int node, int from, int to){
        if(node >= 2*(1<< (int)(log2(N)+1))+100)return -1;
        
        //if node interval doesn't intersect query interval
        if( tree[ node ]._from > to || tree [ node ]._to < from ){
                return -1;
        }
        //node interval inside query interval
        if( tree[ node ]._from >= from && tree[ node ]._to <= to){
                return tree[ node ]._val;
        }
        
        Int lChild = (node*2) + 1;
        Int rChild = (node*2) + 2;
        
        Int r1 = queryTree(lChild, from , to);
        Int r2 = queryTree(rChild, from , to);
        

        if(r1==-1)return r2;
        if(r2==-1)return r1;
        
        Int indx = r1 ;        
        if( vt[ r1 ] < vt[ r2 ] ){
                indx = r1;
        }
        else{
                indx = r2;
        }
return indx;
}


inline void proc(){
        tree.assign(N+100,NODE());
        
        buildTree(0,0,N);
        cout<<"TREE BUILDED\n";
/*
        for (int i = 0; i < SZ(tree); ++i){
                cout<<i<<" : "<<tree[i]._from<<" "<<tree[i]._to<<" "<<tree[i]._val<<"\n";
        }
*/    
        int x, y;
        while(cin>>x>>y ){
                int indx = queryTree(0, x , y);
                cout<<"Minimum value in range "<<x<<" , "<<y<<" is : ";
                cout<<vt[ indx ]<<"\n";
        }
        

return ;
}

int main(){
        read();
        proc();
return 0;
}
